class Queue:
    def __init__(self):
        self.items=[]
    def enqueue(self,item):
        self.items.append(item)
    def dequeue(self):
        return self.items.pop(0)
    def isEmpty(self):
        return self.items==[]
    def size(self):
        return len(self.items)


def JosephVariant(N,M):
    q=Queue()
    queueOrder=[]
    for i in range(1,N+1):
        q.enqueue(i)
    while q.size()>1:
        for _ in range(M-1):
            q.enqueue(q.dequeue())
        M=M+1;
        queueOrder.append(q.dequeue())
    queueOrder.append(q.dequeue())
    return queueOrder
N,M=map(int,input().split(" "))
lt=JosephVariant(N,M)
for i in lt:
    print(i,end=" ")
